package com.tangmu.rabbits.ui.activity.home;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tangmu.rabbits.R;
import com.tangmu.rabbits.adapter.home.MyFragmentPagerAdapter;
import com.tangmu.rabbits.base.BaseActivity;
import com.tangmu.rabbits.ui.fragment.home.NineFragment;
import com.tangmu.rabbits.util.ScreenUtils;
import com.tangmu.rabbits.widget.SlidingTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 9块9包邮
 */
public class NineElementActivity extends BaseActivity {


    @BindView(R.id.iv_header_back)
    ImageView ivHeaderBack;
    @BindView(R.id.iv_header_icon)
    ImageView ivHeaderIcon;
    @BindView(R.id.iv_header_right)
    TextView ivHeaderRight;
    @BindView(R.id.nine_headerView)
    LinearLayout nineHeaderView;
    @BindView(R.id.sliding_tabLayout)
    SlidingTabLayout slidingTabLayout;
    @BindView(R.id.tv_screen_price)
    TextView tvScreenPrice;
    @BindView(R.id.iv_price_up)
    ImageView ivPriceUp;
    @BindView(R.id.iv_price_down)
    ImageView ivPriceDown;
    @BindView(R.id.nine_viewPager)
    ViewPager mViewPager;

    private List<Fragment> fragments = new ArrayList<>();
    private List<String> titles = new ArrayList<>();

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.statusBarColor(R.color.transparent).titleBar(R.id.nine_headerView).init();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_nine_element;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void initView() {
        ivHeaderBack.setImageResource(R.drawable.icon_back);
        ivHeaderBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        ivHeaderIcon.setImageResource(R.drawable.ic_nine_nine);
        ivHeaderRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        initDatas();

        for (int i = 0; i < titles.size(); i++) {
            NineFragment fragment = new NineFragment();
            fragments.add(fragment);
        }

        mViewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments, titles));
        slidingTabLayout.setTabTitleTextSize(14);
        slidingTabLayout.setSelectedIndicatorColors(ContextCompat.getColor(this, R.color.tab_select_color));
        slidingTabLayout.setTabStripWidth((ScreenUtils.getScreenWidth(this) - ScreenUtils.dip2px(this, 80)) / 5 - ScreenUtils.dip2px(this, 30));
        slidingTabLayout.setDistributeEvenly(true);
        slidingTabLayout.setViewPager(mViewPager);
    }

    private void initDatas() {
        titles.add("全部");
        titles.add("女装");
        titles.add("男装");
        titles.add("内衣");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
        titles.add("美妆");
    }
}
